package yang.zhan.zhao.receive.aop;

import cn.hutool.extra.spring.SpringUtil;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;
import yang.zhan.zhao.receive.service.PermissionService;
/**
 * 对接aop
 */
@Aspect
@Component
@Slf4j
public class PermissionAspect {

	@Pointcut("@annotation(permission)")
	protected void excudeService(Permission permission) {
	}

	@Around("excudeService(permission)")
	public Object doAround(ProceedingJoinPoint pjp, Permission permission) {
		try {
			return SpringUtil.getBean(PermissionService.class).action(pjp,permission);
		} catch (Exception e) {
			log.error("场馆aop报错了",e);
			throw new RuntimeException(e);
		}


	}

}
